<% if user_signed_in? %>
<div class='menu'>
<%= link_to 'New article', new_article_path %>
</div>
<% end %>

<h1>Listing articles</h1>

<table>
  <tr>
    <th>Title</th>
    <th>Summary</th>
    <th>User</th>
    <th>Actions</th>
  </tr>
 
  <% @articles.each do |article| %>
    <tr>
      <td><%= article.title %></td>
      <td><%= sanitize article.summary_html %></td>
      <td><%= article.user.email %></td>
      <td><%= link_to 'Show', article_path(article) %>
      <% if user_signed_in? %>
      |<%= link_to 'Edit', edit_article_path(article) %>
      |<%= link_to 'Destroy', article_path(article), method: :delete, data: { confirm: 'Are you sure?' } %>
      <% end %>
      </td>
    </tr>
  <% end %>
</table>
